# -*- coding: utf-8 -*-
# !/usr/resources/python3

import json
from models.Model import Model
from utils.PersonName import PersonName
from sqlalchemy import and_, or_, not_
from models.ResourceChapter import ResourceChapterModel as Chapter
from models.ResourceExclude import ResourceExcludeModel as Exclude

# model
model = Model()


class PersonNameAnalysis:
    # 提取官方名称
    @staticmethod
    def classify(persons, titles):
        official_name = {}
        commonly_name = {}
        other_name = {}
        for i in persons:
            # 检查日常称谓
            if i in titles:
                commonly_name[i] = ''
                continue
            # 拆分姓名
            first_name = i[0:1]
            last_name = i[1:]
            # 判断第一个字是否是姓
            if first_name in PersonName.first_name():
                if last_name not in titles:
                    official_name[i] = ''
                else:
                    commonly_name[i] = ''
            else:
                if first_name in ['小', '大', '老'] and last_name in PersonName.first_name():
                    commonly_name[i] = ''
                else:
                    other_name[i] = ''

        return official_name, commonly_name, other_name
